import s from './index.module.scss';
import axios from 'axios';

const Tabs = ({ tabsData }) => {
  const one = () => {
    return axios.get('http://rap2api.taobao.org/app/mock/288347/test/wrong');
  };
  const two = () => {
    return axios.get('http://rap2api.taobao.org/app/mock/288347/test/getbg');
  };

  const three = () => {
    return axios.get('http://rap2api.taobao.org/app/mock/288347/test/getinfo');
  };
  const isShow = true;
  const testAxiosAll = () => {
    axios.all([isShow ? one() : three(), two()]).then((res) => {
      console.log(res);
    });
  };

  return (
    <div className={s.container}>
      {tabsData &&
        tabsData.map((item) => {
          return (
            <div className={s.tab} key={item.title} onClick={testAxiosAll}>
              <div className={s.tab_top}>
                <img className={s.tab_one} src={item.icon} />
              </div>
              <div className={s.tab_bottom}>{item.title}</div>
            </div>
          );
        })}
    </div>
  );
};

export default Tabs;
